from .SNMP import Wrpc
from .SNMP import Node

def buchang(ip):
    # print(Wrpc.wrpcVersionGroup().walk_wrpcVersionGroup(ip=ip))
    wrpcPtpConfigGroup = Wrpc.wrpcPtpConfigGroup()
    wrpcSfpTable = Wrpc.wrpcSfpTable().walk_wrpcSfpTable(ip=ip)
    # print(wrpcSfpTable)
    DTx = int(wrpcSfpTable["wrpcSfpDeltaTx"])
    DRx = int(wrpcSfpTable["wrpcSfpDeltaRx"])
    input_num = int(input("请输入补偿值(ps)："))
    # input_num = 81390
    DTx = DTx - input_num
    DRx = DRx + input_num
    print(f"\t设置Ptp参数:\n\t\tDTx:{DTx}\tDRx:{DRx}")
    wrpcPtpConfigGroup.set_wrpcPtpConfigDeltaTx(ip=ip,value=DTx)
    wrpcPtpConfigGroup.set_wrpcPtpConfigDeltaRx(ip=ip,value=DRx)
    wrpcPtpConfigGroup.set_wrpcPtpConfigAlphaL(ip=ip,value=73621684)
    wrpcPtpConfigGroup.set_wrpcPtpConfigAlphaH(ip=ip,value=0)
    wrpcPtpConfigGroup.set_wrpcPtpConfigApply(ip=ip,value=2)
    wrpcPtpConfigGroup.set_wrpcPtpConfigApply(ip=ip,value=3)